/**
 * 当前系统日期
 */
var slidint;
// 获取当前系统日期
function newTimer() {
    stopit();
    var today = new Date();
    // 分别取出年、月、日、时、分、秒
    var year = today.getFullYear();
    var month = today.getMonth() + 1;
    var day = today.getDate();
    var hours = today.getHours();
    var minutes = today.getMinutes();
    var seconds = today.getSeconds();
    
    // 如果是单个数，则前面补0
    month = month < 10 ? "0" + month : month;
    day = day < 10 ? "0" + day : day;
    hours = hours < 10 ? "0" + hours : hours;
    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;

    // 构建要输出的字符串
    var date = year + "年" + month + "月" + day + "日 ";
    var time = hours + ":" + minutes + ":" + seconds;
    var str = date + "  " + time + "  " + week();
    var o = document.getElementById("datetime");
    o.innerHTML = str;
    // 刷新日期
    slidint = setTimeout(newTimer, 1000);
}

function stopit() {
    clearTimeout(slidint);
}

// 获取星期
function week() {
    var d, day, x, s = " ";
    var x = new Array("星期日", "星期一", "星期二");
    var x = x.concat("星期三", "星期四", "星期五");
    var x = x.concat("星期六");
    d = new Date();
    day = d.getDay();
    return (s += x[day]);
}
newTimer();

/*function showLocale(objD) {
    var str, colorhead, colorfoot;
    var yy = objD.getYear();
    if (yy < 1900)
        yy = yy + 1900;
    var MM = objD.getMonth() + 1;
    if (MM < 10)
        MM = '0' + MM;
    var dd = objD.getDate();
    if (dd < 10)
        dd = '0' + dd;
    var hh = objD.getHours();
    if (hh < 10)
        hh = '0' + hh;
    var mm = objD.getMinutes();
    if (mm < 10)
        mm = '0' + mm;
    var ss = objD.getSeconds();
    if (ss < 10)
        ss = '0' + ss;
    var ww = objD.getDay();
    if (ww == 0)
        colorhead = "<font color=\"red\">";
    if (ww > 0 && ww < 6)
        colorhead = "<font color=\"red\">";
    if (ww == 6)
        colorhead = "<font color=\"red\">";
    if (ww == 0)
        ww = "星期日";
    if (ww == 1)
        ww = "星期一";
    if (ww == 2)
        ww = "星期二";
    if (ww == 3)
        ww = "星期三";
    if (ww == 4)
        ww = "星期四";
    if (ww == 5)
        ww = "星期五";
    if (ww == 6)
        ww = "星期六";
    colorfoot = "</font>"
    str = colorhead + yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss
            + "  " + ww + colorfoot;
    return (str);
};
function tick() {
    var today;
    today = new Date();
    document.getElementById("datetime").innerHTML = showLocale(today);
    window.setTimeout("tick()", 1000);
};
tick();  */

// 获取系统时间，将时间以指定格式显示到页面。
/*function systemTime() {
    // 获取系统时间。
    var dateTime = new Date();
    var hh = dateTime.getHours();
    var mm = dateTime.getMinutes();
    var ss = dateTime.getSeconds();

    // 分秒时间是一位数字，在数字前补0。
    mm = extra(mm);
    ss = extra(ss);

    // 将时间显示到ID为time的位置，时间格式形如：19:18:02
    document.getElementById("datetime").innerHTML = hh + ":"
            + mm + ":" + ss;

    // 每隔1000ms执行方法systemTime()。
    setTimeout("systemTime()", 1000);
}

// 补位函数。
function extra(x) {
    // 如果传入数字小于10，数字前补一位0。
    if (x < 10) {
        return "0" + x;
    } else {
        return x;
    }
}
systemTime();*/

//定义函数：构建要显示的时间日期字符串
/*function showTime() {
    // 创建Date对象
    var today = new Date();
    // 分别取出年、月、日、时、分、秒
    var year = today.getFullYear();
    var month = today.getMonth() + 1;
    var day = today.getDate();
    var hours = today.getHours();
    var minutes = today.getMinutes();
    var seconds = today.getSeconds();
    // 如果是单个数，则前面补0
    month = month < 10 ? "0" + month : month;
    day = day < 10 ? "0" + day : day;
    hours = hours < 10 ? "0" + hours : hours;
    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;

    // 构建要输出的字符串
    var str = year + "年" + month + "月" + day + "日 " + hours + ":" + minutes
            + ":" + seconds;

    // 获取id=result的对象
    var obj = document.getElementById("datetime");
    // 将str的内容写入到id=result的<div>中去
    obj.innerHTML = str;
    // 延时器
    setTimeout("showTime()", 1000);
}
showTime();*/
